package com.jk1.bianligou.blg.exception;

import com.jk1.bianligou.blg.common.BaseResponse;
import com.jk1.bianligou.blg.common.ErrorCode;
import com.jk1.bianligou.blg.utils.ResultUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author WHH
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(BizException.class)
    public BaseResponse<?> userCenterExceptionHandler(BizException e) {
        log.info("GameMatcherException {}", e.getMessage());
        return ResultUtils.error(e.getCode(), e.getMessage());
    }


    @ExceptionHandler(RuntimeException.class)
    public BaseResponse<?> runTimeExceptionHandler(RuntimeException e) {
        log.info("RuntimeException {}", e.getMessage());
        return ResultUtils.error(ErrorCode.SYSTEM_ERROR, e.getMessage());
    }

}
